<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content-header">
		<ol class="breadcrumb">
			<li><a href="${ctx}/">首页</a></li>
			<li class="active"><a href="#">反馈查询</a></li>
		</ol>
	</section>
	<section class="content">
		<div class="box">
		  <form action="${ctx}/feedbacklist/queryall" method="get">
			<div class="box-header">
				<div class="row RowSearchWork">
					<div class="col-sm-12">
						<div class="col-sm-2" style="display: -webkit-box;">
							<label class="input_text">类型：</label> 
								<select class="form-control" style="width: 200px;" name="feedBackParentType" >
									<option value="">请选择</option>
									<#list parentTypeMap as key, value>
										<#if params?? && params.feedBackParentType?? && (params.feedBackParentType == key)>
											<option value="${key}" selected="selected">${value}</option>
										<#else>
											<option value="${key}" >${value}</option>
										</#if>
									</#list>
								</select>
								<select class="form-control" style="width: 200px; margin-left:20px;" name="feedbackType" >
									<option value="">请选择</option>
								</select>
						</div>
						<div class="col-sm-2" style="margin-left:270px;">
							<label>反馈状态：</label> 
							<select class="form-control" name="feedbackState" >
							   <option value="">请选择</option>
							   <#list feedBackStatus as key, value>
								   <#if params.feedbackState?? && key == params.feedbackState>
										<option value="${key}" selected="selected">${value}</option>
									<#else>
										<option value="${key}">${value}</option>
									</#if>    
							   </#list>
							 </select>
						</div>
						<div class="col-sm-2 three-word">
							<label>申请人：</label> 
							<input name="originator" type="text" class="form-control" placeholder="请输入发起人" value="${params.originator!}"/>
						</div>
						<div class="col-sm-2 width20">
							<label>客户经理：</label> 
							<input name="customerManager" type="text" class="form-control" placeholder="请输入客户经理" value="${params.customerManager!}"/>
						</div>
					</div>
				</div>
				<div class="row RowSearchWork">
					<div class="col-sm-8">
						<div class="col-sm-2 three-word width20">
							<label>关键字：</label> 
							<input name="keyword" type="text" class="form-control" placeholder="请输入编号/标题" value="${params.keyword!}"/>
						</div>
						<div class="col-sm-4" style="display: -webkit-box;">
							<label>申请时间：</label> 
			                <div class="input-group">
			                 	<input type="text" class="form-control" name="starTime" value="${params.starTime!}" id="starTime" autocomplete="off">
			                	<div class="input-group-addon">
			                    	<i>-</i>
			                  	</div>
			                 	<input type="text" class="form-control" name="endTime" value="${params.endTime!}" id="endTime" autocomplete="off">
			                </div>
						</div>
						<div class="col-sm-1 ml60">
							<input type="button" class="btn btn-default btn-search" id="query" value="查询" />
						</div>
					</div>
				</div>
			</div>
			<div class="box-body">
				<table class="table table-hover table-bordered table-striped table-hide">
					<thead>
						<tr>
							<th width="4%">序号</th>
							<th width="11%">编号</th>
							<th width="15%">标题</th>
							<th width="11%">类型</th>
							<th width="8%">申请人</th>
							<th width="11%">申请时间</th>
							<th width="11%">客户经理</th>
							<th width="11%">最新处理时间</th>
							<th width="10%">状态</th>
							<th width="8%">操作</th>
						</tr>
					</thead>
					<tbody>
						<#list page.content as w>
						<tr>
							<td>${page.size*page.number+w_index+1}</td>
							<td>${w.problemFeedBackNo!}</td>
							<td title="${w.title!}">${w.title!}</td>
							<#if w.feedbackType?? && subTypeMap["${w.feedbackType}"]?? >
								<td>${subTypeMap["${w.feedbackType}"]!}</td>
							<#else>
								<td></td>
							</#if>
							<td>${w.createrName!}</td>
							<td>${w.createrTime?string("yyyy-MM-dd HH:mm:ss")}</td>
							<td>${w.customerManager!}</td>
							<td>
								<#if w.lastDealTime?? >
									${w.lastDealTime?string("yyyy-MM-dd HH:mm:ss")}
								</#if>
							</td>
							<td>${feedBackStatus['${w.feedbackState}']}</td>
							<td>
								<a href="${ctx}/feedBack/detail?problemFeedBackId=${w.id}&problemFeedbackRecordId=${w.lastRecordId!}&title=${title}&url=${url}">详情</a>
							</td>
						</tr>
						</#list>
					</tbody>
				</table>
				<#include "../common/page.htm">
			</div>
		 </form>
	  </div>
	</section>
</div>
<#include "../common/footer.htm">

<script type="text/javascript">
	var is_submit=false;
	$(function () {
		$('#starTime').datepicker({
	    	autoclose: true,
	    	format: 'yyyy-mm-dd',
	    	clearBtn: true,
		    language: 'zh-CN'
	    });
		$('#endTime').datepicker({
	    	autoclose: true,
	    	clearBtn: true,
	    	format: 'yyyy-mm-dd',
		    language: 'zh-CN'
	    });
		/* 反馈子类型 */
		var subType = {
			<#list subTypeMap as k, v>
				"${k}": "${v}",
			</#list>
		};
		
		/* 反馈父类型切换 */
		$("select[name='feedBackParentType']").change(function() {
			$("select[name='feedbackType']").html('<option value="">请选择</option>');
			var parentType = $(this).val();
			if (parentType) {
				for (key in subType) {
					if (key.substring(0,key.indexOf('_')) == parentType) {
						$("select[name='feedbackType']").append('<option value="' + key + '">' + subType[key] + '</option>');
					}
				}
			}		
		});
		
		/* 反馈类型汇总 */
		var feedBackMergeType = {
			<#list feedBackMergeTypeMap as k, v>
				"${k}": "${v}",
			</#list>
		};
		/* 设置查询返回类型选中 */
		var feedBackType = "${params.feedbackType!''}";
		var parentType = "${params.feedBackParentType!}";
		if (parentType) {
			for (key in feedBackMergeType) {
				if (key.startsWith(parentType)) {
					if (key == feedBackType) {
						$("select[name='feedbackType']").append('<option value="' + key + '" selected>' + subType[key] + '</option>');
					} else {
						$("select[name='feedbackType']").append('<option value="' + key + '">' + subType[key] + '</option>');
					}
				}
			}
		}
		//查询事件点击校验日期结束日期是否大于开始日期
		$("#query").click(function(){
			$(":input[name='pageNumber']").val(0);
			var startTime = $("#starTime").val();
			var endTime = $("#endTime").val();
			if(null != startTime && null != endTime){
				var start = new Date(startTime.replace("-", "/").replace("-", "/")); 
				var end = new Date(endTime.replace("-", "/").replace("-", "/")); 
				if(end < start){
					var title = "提示!";
					base.getView({
						url:"${ctx}/feedbacklist/prompt",
						success:function(result){
							bootbox.dialog({
								title:title,
								message:result,
								size:"small",
								closeButton : false,
								buttons:{
									cancel:{
										label:"确认",
										className:"btn btn btn-primary"
									}
								}
							})
						}
					})
					$("#endTime").val("");
				}else{
					
					$("#query").submit();
				}
			}
		});
	})
	
</script>